package fi.vamk.android;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

public class Map extends Activity  {
	private GoogleMap mMap;
	private static final LatLng VassaLatLng = new LatLng(30, 65200);
	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map);
        setUpMapIfNeeded();
     }
	private void setUpMapIfNeeded() {
	    // Do a null check to confirm that we have not already instantiated the map.
	    if (mMap == null) {
	        mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
	                            .getMap();
	        // Check if we were successful in obtaining the map.
	        if (mMap != null) {
	            // The Map is verified. It is now safe to manipulate the map.
	        	mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
	        	mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(VassaLatLng, 15));
	        	mMap.animateCamera(CameraUpdateFactory.zoomIn());
	        }
	    }
	}
	 @Override
	    public boolean onCreateOptionsMenu(Menu menu) {
	        MenuInflater inflater = getMenuInflater();
	        inflater.inflate(R.layout.menu_button, menu);
	        return true;
	    }
	    @Override
	    public boolean onOptionsItemSelected(MenuItem item) {
	        // Handle item selection
	        switch (item.getItemId()) {
	        case R.id.exit:
	        	finish();
	            return true;
	        case R.id.list:
	        	startActivity(new Intent(Map.this, menuList.class));
	         	finish();
	            return true;
	        default:
	            return super.onOptionsItemSelected(item);
	        }
	    }
    
	public void alertOkOnly(String title, String message)
    {
    	AlertDialog.Builder builder=
        	new AlertDialog.Builder(Map.this);
        	builder
        	.setTitle(title)
        	.setMessage(message)
        	.setPositiveButton("OK", null)
        	.show();
    } 
}